package com.zline.foodraise.view;

import android.content.Context;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zline.foodraise.R;
import com.zline.foodraise.entity.UserAddressBean;
import com.zline.foodraise.listener.RecyclerItemClicked;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by heshantao on 15/7/4.
 * 历史收货地址Item
 */
@EViewGroup(R.layout.addr_list_item)
public class AddrListItem extends RelativeLayout {
    private static final String LOG_TAG = AddrListItem.class.getSimpleName();
    @ViewById(R.id.addr_list_item_tv)
    TextView tv;
    RecyclerItemClicked itemClicked;
    int position;

    public AddrListItem(Context context) {
        super(context);
    }

    public void bind(UserAddressBean userAddressBean,int position) {
        String info=userAddressBean.getPreAddr()+userAddressBean.getSubAddr()+userAddressBean.getDetailAddr();
        tv.setText(info);
        this.position=position;
    }

    public void setListener(RecyclerItemClicked listener){
        this.itemClicked=listener;
    }

    @Click(R.id.addr_item_rl)
    void onClick(){
        itemClicked.onRecyclerItemClicked(position);
    }

}
